//
//  SchedulingRecordView.m
//  Pad-test
//
//  Created by jayce on 17/3/24.
//  Copyright © 2017年 jjkj. All rights reserved.
//

#import "SchedulingRecordView.h"
#import "InsetsLabel.h"

#define kStartPointX 32
#define kStartPointY 58
#define kNameWidth 118
#define kSecurityWidth 172
#define kTotalWidth 516
#define kHeigth 34
#define kH1 90
#define kH2 148
#define kH3 48
#define kH4 100
#define kH5 68
#define kFrameHeight(X) X.frame.size.height
#define KFrameX(X) X.frame.origin.x
#define KFrameY(X) X.frame.origin.y


@implementation SchedulingRecordView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame: frame];
    if (self) {
         [self initSubView];
    }
    return self;
}
- (void)setModel:(SchedulingRecordsModel *)model{
    _model = model;
    self.recordOfDateL.text = model.recordOfDate;
    //self.dayImg.image = ;
    //self.showImgView.image = model.imageName.length > 0 ? [UIImage imageNamed:model.imageName] : nil;
    self.directorNameL.text = model.directorName;
    self.monitorNameL.text = model.monitorName;
    self.dispatcherNameL.text = model.dispatcherName;
    self.ledIndicatorL.text = model.ledIndicator;
    self.schedulingRecordsL.text = model.schedulingRecords;

    self.firePreventionL.text = model.firePrevention;
    self.workingConditionL.text = model.workingCondition;
    self.safetyProtectionL.text = model.safetyProtection;
    self.outageRecordsL.text = model.outageRecords;
    self.otherL.text = model.other;
    
}
- (void)initSubView{
    
    //日期
    self.recordOfDateL = [[UILabel alloc]initWithFrame:CGRectMake(220, 18, 109, 31)];
    [self.recordOfDateL setFont:[UIFont boldSystemFontOfSize:16]];
    [self addSubview:self.recordOfDateL];
    
    //早晚班
    self.dayImg = [[UIImageView alloc]initWithFrame:CGRectMake(343, 13, 40, 40)];
    self.dayImg.image = [UIImage imageNamed:@"btn"];
    [self addSubview:self.dayImg];
    
    //值班主任
    InsetsLabel *directorT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, kStartPointY, kNameWidth, kHeigth)];
    directorT.text = @"值班主任";
    [self addSubview:directorT];
    
    self.directorNameL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX+kNameWidth-1, kStartPointY, kTotalWidth-kNameWidth+1, kHeigth) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    [self addSubview:self.directorNameL];
    
    //班长
    InsetsLabel *monitorT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(self.directorNameL)+kHeigth-1, kNameWidth, kHeigth)];
    monitorT.text = @"班    长";
    [self addSubview:monitorT];
    
    self.monitorNameL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX+kNameWidth-1, KFrameY(self.directorNameL)+kHeigth-1, kTotalWidth-kNameWidth+1, kHeigth) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    [self addSubview:self.monitorNameL];
    
    //调度
    InsetsLabel *dispatcherT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(self.monitorNameL)+kHeigth-1, kNameWidth, kHeigth)];
    dispatcherT.text = @"调    度";
    [self addSubview:dispatcherT];
    
    self.dispatcherNameL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX+kNameWidth-1, KFrameY(self.monitorNameL)+kHeigth-1, kTotalWidth-kNameWidth+1, kHeigth) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    [self addSubview:self.dispatcherNameL];
    
    //领导指示
    InsetsLabel *ledIndicatorT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(self.dispatcherNameL)+kHeigth-1, kTotalWidth, kHeigth)];
    ledIndicatorT.text = @"领导指示";
    [ledIndicatorT setFont:[UIFont boldSystemFontOfSize:18]];
    [self addSubview:ledIndicatorT];
    
    self.ledIndicatorL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(ledIndicatorT)+kHeigth-1, kTotalWidth, kH1) andInsets:UIEdgeInsetsMake(5, 10, 0, 0)];
    self.ledIndicatorL.numberOfLines = 0;
    [self addSubview:self.ledIndicatorL];
    
    //调度会记录
    InsetsLabel *schedulingRecordsT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(self.ledIndicatorL)+kH1-1, kTotalWidth, kHeigth)];
    schedulingRecordsT.text = @"调度会记录";
    [schedulingRecordsT setFont:[UIFont boldSystemFontOfSize:18]];
    [self addSubview:schedulingRecordsT];
    
    self.schedulingRecordsL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(schedulingRecordsT)+kHeigth-1, kTotalWidth, kH2) andInsets:UIEdgeInsetsMake(5, 10, 0, 0)];
    self.schedulingRecordsL.numberOfLines = 0;
    [self addSubview:self.schedulingRecordsL];
    
    //安全情况
    InsetsLabel *safeT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(self.schedulingRecordsL)+kH2-1, kTotalWidth, kHeigth)];
    safeT.text = @"安全情况";
    [safeT setFont:[UIFont boldSystemFontOfSize:18]];
    [self addSubview:safeT];
    
    //防火
    InsetsLabel *fireL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(safeT)+kHeigth-1, kSecurityWidth, kH3) andInsets:UIEdgeInsetsMake(0, 53, 0, 53)];
    fireL.numberOfLines = 0;
    fireL.text = @"防火工具绝缘保护";
    [self addSubview:fireL];
    
    //作业条件
    InsetsLabel *conditionL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX+kSecurityWidth-1, KFrameY(safeT)+kHeigth-1, kSecurityWidth+1, kH3) andInsets:UIEdgeInsetsMake(0, 53, 0, 53)];
    conditionL.numberOfLines = 0;
    conditionL.text = @"作业条件环境因素";
    [self addSubview:conditionL];
    
    //安全防范
    InsetsLabel *protectL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX+2*kSecurityWidth-1, KFrameY(safeT)+kHeigth-1, kSecurityWidth+1, kH3) andInsets:UIEdgeInsetsMake(0, 53, 0, 53)];
    protectL.numberOfLines = 0;
    protectL.text = @"安全防范  措施";
    [self addSubview:protectL];
    
    self.firePreventionL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(fireL)+kH3-1, kSecurityWidth, kH4) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    self.firePreventionL.numberOfLines = 0;
    [self addSubview:self.firePreventionL];
    
    self.workingConditionL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX+kSecurityWidth-1, KFrameY(fireL)+kH3-1, kSecurityWidth+1, kH4) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    self.workingConditionL.numberOfLines = 0;
    [self addSubview:self.workingConditionL];
    
    self.safetyProtectionL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX+2*kSecurityWidth-1, KFrameY(fireL)+kH3-1, kSecurityWidth+1, kH4) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    self.safetyProtectionL.numberOfLines = 0;
    [self addSubview:self.safetyProtectionL];
    
    //停送电记录
    InsetsLabel *outT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(self.firePreventionL)+kH4-1, kTotalWidth, kHeigth)];
    outT.text = @"停送电记录";
    [outT setFont:[UIFont boldSystemFontOfSize:18]];
    [self addSubview:outT];
    
    self.outageRecordsL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(outT)+kHeigth-1, kTotalWidth, kH5) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    self.outageRecordsL.numberOfLines = 0;
    [self addSubview:self.outageRecordsL];
    
    //其他
    InsetsLabel *otherT = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(self.outageRecordsL)+kH5-1, kTotalWidth, kHeigth)];
    otherT.text = @"其他";
    [otherT setFont:[UIFont boldSystemFontOfSize:18]];
    [self addSubview:otherT];
    
    self.otherL = [[InsetsLabel alloc]initWithFrame:CGRectMake(kStartPointX, KFrameY(otherT)+kHeigth-1, kTotalWidth, kH5) andInsets:UIEdgeInsetsMake(0, 10, 0, 0)];
    self.otherL.numberOfLines = 0;
    [self addSubview:self.otherL];
    
    
    if (self.heightBlock) {
        self.heightBlock(100);
    }
}

@end
